package com.ch06.controller;

import com.ch06.controller.vo.ResultVO;
import com.ch06.entity.User;
import com.ch06.service.AuthService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName AuthController
 * @Description TODO
 * @Author Kx
 * @Date 2025/5/13 11:53
 * @Version 1.0
 */
// 标识为控制器并可以解析JSON数据
@RestController
public class AuthController extends BaseController{

    // 业务层对象
    private AuthService service;

    public AuthController(AuthService service) {
        this.service = service;
    }

    /**
     * @author: kx
     * @date: 2025/5/13 15:27
     * @param account : 账号
     * @param password : 密码
     * @return com.ch06.controller.vo.ResultVO<com.ch06.entity.User>
     * @description: 登录验证
    */
    @GetMapping("/auth")
    public ResultVO<User> login(@RequestParam("account") String account,@RequestParam("password") String password) {
        User user = service.getUser(account, password);
        return success(user);
    }
}
